package com.autonavi.yunda.yunji.controller.request;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import com.autonavi.yunda.yunji.core.enums.DatasourceType;
import com.autonavi.yunda.yunji.core.model.dto.DatasourceConfigDTO;
import lombok.Data;
import java.util.List;

/**
 * @author sunzhenbang
 */
@Data
public class DatasourceConfigRequest {
    private Long id;
    @NotBlank
    private String dbname;
    private String description;
    @NotNull
    private DatasourceType type;
    @NotBlank
    private String config;
    private String operator;
    private String isDeleted;
    private List<String> projectIds;
    public DatasourceConfigDTO toAddDTO() {
        return DatasourceConfigDTO.builder()
            .dbname(dbname)
            .type(type)
            .config(config)
            .description(description)
            .createUser(operator)
            .updateUser(operator)
            .build();

    }

    public DatasourceConfigDTO toUpdateDTO(DatasourceConfigDTO updateDTO) {
         updateDTO.setDbname(dbname);
         updateDTO.setType(type);
         updateDTO.setConfig(config);
         updateDTO.setDescription(description);
         updateDTO.setUpdateUser(operator);
        return updateDTO;
    }
}
